"""
调试AKShare API返回的数据结构
"""

import akshare as ak
import pandas as pd

def debug_akshare_data():
    """调试AKShare返回的数据结构"""
    try:
        print("正在获取贵州茅台(600519)的资产负债表数据...")
        data = ak.stock_balance_sheet_by_report_em(symbol="SH600519")
        
        print(f"数据形状: {data.shape}")
        print(f"列名: {list(data.columns)}")
        print("\n前5行数据:")
        print(data.head())
        
        print("\n数据类型:")
        print(data.dtypes)
        
        # 保存到CSV文件以便查看
        data.to_csv("akshare_raw_data.csv", index=False, encoding='utf-8-sig')
        print("\n原始数据已保存到 akshare_raw_data.csv")
        
        return data
        
    except Exception as e:
        print(f"获取数据失败: {e}")
        return None

if __name__ == "__main__":
    debug_akshare_data()
